How to select li range and move them inside div [closed]

Posted by user8012 on Programmers See other posts from Programmers or by user8012
Published on 2012-09-10T01:07:28Z Indexed on 2012/09/10 3:48 UTC
Read the original article Hit count: 274

Filed under:
|
|

How can I select a range of li and move them inside div element.

For example:

<ul>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
  <li>test</li>
</ul>

If the li is more than 6 create a column like this:

<ul>
  <li>
    <div class="column1">
      <ul>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
      </ul>
    </div>
  </li>
  <li>
    <div class="column2">
      <ul>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
        <li>test</li>
      </ul>
    </div>
  </li>
</ul>

© Programmers or respective owner

Related posts about JavaScript

Related posts about jQuery